import 'dart:convert';

/// id : 100000
/// msg : {"img":null,"text":null}
/// time : 10032
/// type : 0

Message messageFromJson(String str) => Message.fromJson(json.decode(str));
String messageToJson(Message data) => json.encode(data.toJson());

/// type 消息类型
/// 0 表示普通消息
///  msg: {
///   "text" : "消息内容"
///  }
///  1 表示图片消息
///  msg: {
///   "img" : "http://sfaef.jpg"
///  }
class Message {
  Message({
      int? id, 
      Msg? msg, 
      int? time, 
      int? type,}){
    _id = id;
    _msg = msg;
    _time = time;
    _type = type;
}

  Message.fromJson(dynamic json) {
    _id = json['id'];
    _msg = json['msg'] != null ? Msg.fromJson(json['msg']) : null;
    _time = json['time'];
    _type = json['type'];
  }
  int? _id;
  Msg? _msg;
  int? _time;
  int? _type;

  int? get id => _id;
  Msg? get msg => _msg;
  int? get time => _time;
  int? get type => _type;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = _id;
    if (_msg != null) {
      map['msg'] = _msg?.toJson();
    }
    map['time'] = _time;
    map['type'] = _type;
    return map;
  }

}

/// img : null
/// text : null

Msg msgFromJson(String str) => Msg.fromJson(json.decode(str));
String msgToJson(Msg data) => json.encode(data.toJson());
class Msg {
  Msg({
      String? img,
      String? text,}){
    _img = img;
    _text = text;
}

  Msg.fromJson(dynamic json) {
    _img = json['img'];
    _text = json['text'];
  }
  dynamic _img;
  dynamic _text;

  dynamic get img => _img;
  dynamic get text => _text;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['img'] = _img;
    map['text'] = _text;
    return map;
  }

}